package org.mobai.flow.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 节点审批人类型
 *
 * @author mobai
 */

@AllArgsConstructor
@Getter
public enum AssigneeTypeEnum {
    USER("user", "${camundaGetUserHandle.getUserIdList(%s)}"),
    ROLE("role", "${camundaGetUserHandle.getUserIdListByRoles(%s)}"),
    SELF("self", "${camundaGetUserHandle.getStartUser(execution)}"),

    ;
    private final String type;
    private final String script;
    private static final Map<String, AssigneeTypeEnum> ASSIGNEE_TYPE_ENUM_MAP = new HashMap<>();

    static {
        for (AssigneeTypeEnum value : AssigneeTypeEnum.values()) {
            ASSIGNEE_TYPE_ENUM_MAP.put(value.getType(), value);
        }
    }

    public static AssigneeTypeEnum getByType(String type) {
        return ASSIGNEE_TYPE_ENUM_MAP.get(type);
    }
}
